﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Architecture.Linq;
using System.ComponentModel;

namespace Emerald.Business.Controllers
{
    /// <summary>
    /// 
    /// </summary>
    public class ForumController : GenericController<Forum, EmeraldDataContext>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [DataObjectMethod(DataObjectMethodType.Select)]
        public IQueryable<Forum> GetChildForums()
        {
            IQueryable<Forum> result = from forum in EntityTable
                                       where !forum.ParentForumId.HasValue
                                       select forum;

            return result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [DataObjectMethod(DataObjectMethodType.Select)]
        public IQueryable<Forum> GetChildForums(int id)
        {
            IQueryable<Forum> result =  from forum in EntityTable
                                        where forum.ParentForumId == id
                                        select forum;

            return result;
        }
    }
}
